package org.jeecg.common.util;


import org.jeecg.common.model.Callable;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

/**
 * 获取泛型工具
 * @author 3hmzz
 */
public class GenericUtil {

    public static Type[] getGeneric(Class cla){
        ParameterizedType genericSuperclass = (ParameterizedType) cla.getGenericSuperclass();
        Type[] actualTypeArguments = genericSuperclass.getActualTypeArguments();
        return actualTypeArguments;
    }
    public static <T> T getGeneric(Class cla, Callable<Type[],T> callable){
        ParameterizedType genericSuperclass = (ParameterizedType) cla.getGenericSuperclass();
        Type[] actualTypeArguments = genericSuperclass.getActualTypeArguments();
        return callable.callback(actualTypeArguments);
    }
}
